package com.example.zbh.dsliao.presenter;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 * Created by zbh on 15/11/16.
 */
public class BasePresenter<T> {
    protected Reference<T> tReference;

    public void attachView(T t){
        tReference = new WeakReference<T>(t);
    }

    protected T getView(){
        return tReference.get();
    }
    public boolean isViewAttach(){
        return (tReference!= null && tReference.get()!= null);
    }
    public void detachView(){
        if (tReference != null){
            tReference.clear();
            tReference = null;
        }
    }
}
